﻿<UserControl x:Class="Hisaab.Client.Modules.Core.Dashboard.View.DashboardView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             xmlns:h="clr-namespace:Hisaab.Client.Common.Helpers;assembly=Hisaab.Client.Common" xmlns:Converters="clr-namespace:Hisaab.Client.Modules.Core.Converters" mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Converters:AccountTypeImageConverter x:Key="accountImageConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="6"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="300"/>
            <RowDefinition Height="6"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <ListBox Grid.Column="0"  Grid.RowSpan="3" ItemsSource="{Binding Path=AccountTotals}" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="20" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Image Grid.Column="0" Grid.RowSpan="2" Source="{Binding Key.AccountType, Converter={StaticResource accountImageConverter}}" Margin="0,0,5,0" />
                        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Key.Name}" />
                        <TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding Value, StringFormat='{}{0:C}'}" HorizontalAlignment="Right" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <GridSplitter Grid.Column="1"  Grid.RowSpan="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
        <charting:Chart  Grid.Column="2" Grid.Row="0"
            h:ChartHelper.DependentValueBinding="CumulativeTotal"
            h:ChartHelper.IndependentValueBinding="Month"
            h:ChartHelper.Title="{Binding Title}"
            h:ChartHelper.SeriesType="Line"
            h:ChartHelper.SeriesSource="{Binding Path=MonthlyTotals}" >
        </charting:Chart>
        <GridSplitter Grid.Column="2"  Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
    </Grid>
</UserControl>